
import { _decorator, Component, Node, ProgressBar, assetManager, AssetManager, director } from 'cc';
import { ResMgr } from '../script/Mgr/ResMgr';
const { ccclass, property } = _decorator;

@ccclass('InitView')
export class InitView extends Component {

    @property(ProgressBar) progressBar: ProgressBar = null!


    start() {
        // [3]
        let op: any = {};
        //bind改变this指向 执行loadProgress的人是InitView 不是op
        op.onFileProgress = this.loadPress.bind(this);
        assetManager.loadBundle('res', this.bundleResult)

        //更新进度条
        //加载进度条
    }

    loadPress(res: any) {
        this.progressBar.progress = res.progress;
    }

    bundleResult(err: Error | null, bundle: AssetManager.Bundle) {
        ResMgr.m_bundle = bundle;
        director.loadScene('home')
        // InitView.runScence();

    }

    runScence() {
        director.loadScene('home')
    }





}

